package android.content.pm;

import android.util.AndroidException;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author slc
 * @date 2022/03/30 下午 4:19
 */
public class PackageManager {
    private final Map<String, PackageInfo> packageInfoMap = new ConcurrentHashMap<>();

    public PackageManager() {
    }

    public void addPackageInfo(String packageName, PackageInfo packageInfo) {
        packageInfoMap.put(packageName, packageInfo);
    }

    public PackageInfo getPackageInfo(String packageName, int flags) throws NameNotFoundException {
        if (packageInfoMap.containsKey(packageName)) {
            return packageInfoMap.get(packageName);
        }
        throw new NameNotFoundException("");
    }

    public static class NameNotFoundException extends AndroidException {
        public NameNotFoundException() {
        }

        public NameNotFoundException(String name) {
            super(name);
        }
    }
}
